
// ########################
// event handlers

//TODO: only register event handlers after page load.

//keydown event listener
$(document).keydown(function(e){

	var isSelectionChanged = false;

	switch(e.keyCode) {
		case 37: // left
			model.selectPrevOnXAxis();
			updateHTMLForSelectedDataPoint(
				model.getSelectedDataPointXIndexName(),
				model.getSelectedDataPointYValue(),
				model.getSelectedDataPointZIndexName());
			return false; // dont bubble event to other listeners
		case 39: // right
			model.selectNextOnXAxis();
			updateHTMLForSelectedDataPoint(
				model.getSelectedDataPointXIndexName(),
				model.getSelectedDataPointYValue(),
				model.getSelectedDataPointZIndexName());
			return false; // dont bubble event to other listeners
		case 38: // up
			model.selectNextOnZAxis();
			updateHTMLForSelectedDataPoint(
				model.getSelectedDataPointXIndexName(),
				model.getSelectedDataPointYValue(),
				model.getSelectedDataPointZIndexName());
			return false; // dont bubble event to other listeners
		case 40: // down
			model.selectPrevOnZAxis();
			updateHTMLForSelectedDataPoint(
				model.getSelectedDataPointXIndexName(),
				model.getSelectedDataPointYValue(),
				model.getSelectedDataPointZIndexName());
			return false; // dont bubble event to other listeners
		default: break;
	}
	return true; // bubble event to other listeners
});


